#!/bin/bash

# postinst script for driver-network-e1000g
#
# see: dh_installdeb(1)

#set -e

# summary of how this script can be called:
#        * <postinst> \`configure' <most-recently-configured-version>
#        * <old-postinst> \`abort-upgrade' <new version>
#        * <conflictor's-postinst> \`abort-remove' \`in-favour' <package>
#          <new-version>
#        * <postinst> \`abort-remove'
#        * <deconfigured's-postinst> \`abort-deconfigure' \`in-favour'
#          <failed-install-package> <version> \`removing'
#          <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package

PATH=/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin
export PATH

if [ "${BASEDIR:=/}" = "/" ]; then
    BASEDIR=""
else
    BASEDIR_OPT="-b $BASEDIR"
fi

case "$1" in
    configure)
        chown root:bin $BASEDIR/usr/share/man/man4d
	chown root:bin $BASEDIR/usr/share/man
	chown root:sys $BASEDIR/kernel
	chown root:sys $BASEDIR/kernel/drv
	chown root:sys $BASEDIR/kernel/drv/amd64
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/kernel/drv/e1000g.conf ] && rm -f $BASEDIR/kernel/drv/e1000g.conf
	else
	    [ -f $BASEDIR/kernel/drv/e1000g.conf ] || cp -ax $BASEDIR/usr/share/doc/driver-network-e1000g/examples/e1000g.conf $BASEDIR/kernel/drv/e1000g.conf
	    chmod 0644 "$BASEDIR/kernel/drv/e1000g.conf"
	    chown root:sys "$BASEDIR/kernel/drv/e1000g.conf"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/kernel/drv/amd64/e1000g ] && rm -f $BASEDIR/kernel/drv/amd64/e1000g
	else
	    chmod 0755 "$BASEDIR/kernel/drv/amd64/e1000g"
	    chown root:sys "$BASEDIR/kernel/drv/amd64/e1000g"
	fi
	[ "$ZONEINST" = "1" ] || (grep -c "^e1000g " $BASEDIR/etc/name_to_major >/dev/null || ( add_drv -n  $BASEDIR_OPT  -i '"pci8086,d4c,p" "pci8086,d4d,p" "pci8086,d4e,p" "pci8086,d4f,p" "pci8086,d53,p" "pci8086,d55,p" "pci8086,dc5,p" "pci8086,dc6,p" "pci8086,dc7,p" "pci8086,dc8,p" "pci8086,1000" "pci8086,1001" "pci8086,1004.0e11.49" "pci8086,1004.0e11.b1a4" "pci8086,1004.1014.10f2" "pci8086,1004.8086.1004" "pci8086,1004.8086.2004" "pci8086,1008" "pci8086,1009" "pci8086,100c" "pci8086,100d" "pci8086,100e" "pci8086,100f" "pci8086,1010" "pci8086,1011" "pci8086,1012" "pci8086,1013" "pci8086,1014" "pci8086,1015" "pci8086,1016" "pci8086,1017" "pci8086,1018" "pci8086,1019" "pci8086,101a" "pci8086,101d" "pci8086,101e" "pci8086,1026" "pci8086,1027" "pci8086,1028" "pci8086,1049" "pci8086,104a" "pci8086,104b" "pci8086,104c" "pci8086,104d" "pci8086,105a" "pci8086,105b" "pci8086,105c" "pci8086,105e" "pci8086,105f" "pci8086,1060" "pci8086,1061" "pci8086,1062" "pci8086,1063" "pci8086,1075" "pci8086,1076" "pci8086,1077" "pci8086,1078" "pci8086,1079" "pci8086,107a" "pci8086,107b" "pci8086,107c" "pci8086,107d" "pci8086,107e" "pci8086,107f" "pci8086,108a" "pci8086,108b" "pci8086,108c" "pci8086,1096" "pci8086,1098" "pci8086,1099" "pci8086,109a" "pci8086,10a4" "pci8086,10a5" "pci8086,10b5" "pci8086,10b9" "pci8086,10ba" "pci8086,10bb" "pci8086,10bc" "pci8086,10bd" "pci8086,10bf" "pci8086,10c0" "pci8086,10c2" "pci8086,10c3" "pci8086,10c4" "pci8086,10c5" "pci8086,10cb" "pci8086,10cc" "pci8086,10cd" "pci8086,10ce" "pci8086,10d3" "pci8086,10d5" "pci8086,10d9" "pci8086,10da" "pci8086,10de" "pci8086,10df" "pci8086,10e5" "pci8086,10ea" "pci8086,10eb" "pci8086,10ef" "pci8086,10f0" "pci8086,10f5" "pci8086,10f6" "pci8086,1502" "pci8086,1503" "pci8086,150c" "pci8086,153a" "pci8086,153b" "pci8086,1559" "pci8086,155a" "pci8086,156f" "pci8086,1570" "pci8086,15a0" "pci8086,15a1" "pci8086,15a2" "pci8086,15a3" "pci8086,15b7" "pci8086,15b8" "pci8086,15b9" "pci8086,15bb" "pci8086,15bc" "pci8086,15bd" "pci8086,15be" "pci8086,15d6" "pci8086,15d7" "pci8086,15d8" "pci8086,15df" "pci8086,15e0" "pci8086,15e1" "pci8086,15e2" "pci8086,15e3" "pci8086,15f4,p" "pci8086,15f5,p" "pci8086,15f9,p" "pci8086,15fa,p" "pci8086,15fb,p" "pci8086,15fc,p" "pci8086,1a1c,p" "pci8086,1a1d,p" "pci8086,1a1e,p" "pci8086,1a1f,p" "pci8086,294c" "pci8086,550a,p" "pci8086,550b,p" "pci8086,550c,p" "pci8086,550d,p" "pci8086,550e,p" "pci8086,550f,p" "pci8086,5510,p" "pci8086,5511,p" "pci8086,f0fe" "pciex8086,d4c" "pciex8086,d4d" "pciex8086,d4e" "pciex8086,d4f" "pciex8086,d53" "pciex8086,d55" "pciex8086,dc5" "pciex8086,dc6" "pciex8086,dc7" "pciex8086,dc8" "pciex8086,1049" "pciex8086,104a" "pciex8086,104b" "pciex8086,104c" "pciex8086,104d" "pciex8086,105e" "pciex8086,105f" "pciex8086,1060" "pciex8086,107d" "pciex8086,107e" "pciex8086,107f" "pciex8086,108b" "pciex8086,108c" "pciex8086,1096" "pciex8086,1098" "pciex8086,109a" "pciex8086,10a4" "pciex8086,10a5" "pciex8086,10b9" "pciex8086,10ba" "pciex8086,10bb" "pciex8086,10bc" "pciex8086,10bd" "pciex8086,10bf" "pciex8086,10c0" "pciex8086,10c2" "pciex8086,10c3" "pciex8086,10c4" "pciex8086,10c5" "pciex8086,10cb" "pciex8086,10cc" "pciex8086,10cd" "pciex8086,10ce" "pciex8086,10d3" "pciex8086,10d5" "pciex8086,10d9" "pciex8086,10da" "pciex8086,10de" "pciex8086,10df" "pciex8086,10e5" "pciex8086,10ea" "pciex8086,10eb" "pciex8086,10ef" "pciex8086,10f0" "pciex8086,10f5" "pciex8086,10f6" "pciex8086,1502" "pciex8086,1503" "pciex8086,150c" "pciex8086,153a" "pciex8086,153b" "pciex8086,1559" "pciex8086,155a" "pciex8086,156f" "pciex8086,1570" "pciex8086,15a0" "pciex8086,15a1" "pciex8086,15a2" "pciex8086,15a3" "pciex8086,15b7" "pciex8086,15b8" "pciex8086,15b9" "pciex8086,15bb" "pciex8086,15bc" "pciex8086,15bd" "pciex8086,15be" "pciex8086,15d6" "pciex8086,15d7" "pciex8086,15d8" "pciex8086,15df" "pciex8086,15e0" "pciex8086,15e1" "pciex8086,15e2" "pciex8086,15e3" "pciex8086,15f4" "pciex8086,15f5" "pciex8086,15f9" "pciex8086,15fa" "pciex8086,15fb" "pciex8086,15fc" "pciex8086,1a1c" "pciex8086,1a1d" "pciex8086,1a1e" "pciex8086,1a1f" "pciex8086,294c" "pciex8086,550a" "pciex8086,550b" "pciex8086,550c" "pciex8086,550d" "pciex8086,550e" "pciex8086,550f" "pciex8086,5510" "pciex8086,5511" "pciex8086,f0fe"' -m '* 0666 root sys' e1000g ) )
	[ "$ZONEINST" = "1" ] || (grep -c "'e1000g 0666 root sys'" $BASEDIR/etc/minor_perm >/dev/null || update_drv -n  -a $BASEDIR_OPT  -m 'e1000g 0666 root sys' clone)
	
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)
    ;;

    *)
        echo "postinst called with unknown argument '$1'" >&2
        exit 1
    ;;
esac



# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0

